<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of orderstats
 *
 * @author b4by
 */
class order_p extends MY_Controller {

	function __construct() {
		parent::__construct();
		$this->load->model('model_product');
		$this->load->model('model_order');
	}

	public function index() {
		$this->data['temp'] = 'admin/order_p/index';
		$this->load->view('admin/main', $this->data);
	}

	public function read() {
		
		$pagination = pagination_init($this->model_product->get_total(array(
			'total_orders >' => 0,
			'active' => 1,
		)), request('p',1));
		
		$products = $this->model_product->get_list($this->user_lang->id,array(
			'where' => array(
				'total_orders >' => 0,
				'active' => 1,
			),
			'limit'	=> array($pagination->from,$pagination->limit)
		));
		foreach($products as &$product){
			$product->detail_link = url_create('admin','order_o','index',$product->id);
			$product->thumb = image_url($product->thumb);
		}
		echo json_encode(array(
			'state'	=> 'success',
			'data'	=>	$products,
			'pagination'	=> $pagination,
		));
	}
}

?>
